Skip to content

Restart extractor on config change#655

Open
Toshad wants to merge 7 commits intomasterfrom
config_restart
Open

Restart extractor on config change#655
Toshad wants to merge 7 commits intomasterfrom
config_restart

Conversation

@Toshad
Copy link
Copy Markdown

@Toshad Toshad commented Apr 9, 2026

Currently, we restart on config change only if restart policy is 'always' but we also want to restart for other cases to support integrations.

@Toshad Toshad requested a review from a team as a code owner April 9, 2026 06:13
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.98%. Comparing base (8724278) to head (19b2c5d).

Files with missing lines Patch % Lines
ExtractorUtils/Unstable/Runtime/Runtime.cs 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #655      +/-   ##
==========================================
- Coverage   78.07%   77.98%   -0.10%     
==========================================
  Files         136      136              
  Lines       13228    13240      +12     
  Branches     1991     1993       +2     
==========================================
- Hits        10328    10325       -3     
- Misses       2063     2075      +12     
- Partials      837      840       +3     
Files with missing lines Coverage Δ
ExtractorUtils/Unstable/Runtime/Runtime.cs 61.74% <83.33%> (-2.55%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Toshad
Copy link
Copy Markdown
Author

Toshad commented Apr 9, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new ExtractorRunResult.RestartRequired state to the extractor runtime, allowing for clean shutdowns that still necessitate a restart, particularly when a configuration revision changes. The Run and BuildAndRunExtractor methods have been updated to handle this new state, including logging relevant information and setting appropriate backoff. Unit tests were also updated to reduce backoff times and explicitly set the restart policy to OnError for testing config change scenarios. There are no review comments to address.

Copy link
Copy Markdown
Contributor

@Hmnt39 Hmnt39 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this restart trigger will only be done on remote config changes or local remote will also do it ?

@Toshad
Copy link
Copy Markdown
Author

Toshad commented Apr 10, 2026

Is this restart trigger will only be done on remote config changes or local remote will also do it ?

If connection config is set to local, then it will do it.

If connection config is set to 'no connection', Then it will not do it.

I think this is correct behaviour.

@Toshad Toshad requested a review from Hmnt39 April 10, 2026 12:06
@Toshad Toshad added the waiting-for-risk-review Waiting for a member of the risk review team to take an action label Apr 12, 2026
@aasmundeldhuset aasmundeldhuset self-assigned this Apr 14, 2026
@aasmundeldhuset aasmundeldhuset added the risk-review-ongoing Risk review is in progress label Apr 14, 2026
Copy link
Copy Markdown

@aasmundeldhuset aasmundeldhuset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦄

I only have style feedback; the two that are in scope of this PR are small enough that you can ignore them if you want - but I strongly recommend breaking down the large function to make it easier to see the high-level flow (in a separate PR).

// Otherwise, immediately restart.
backoff = 0;
}
else if (result == ExtractorRunResult.RestartRequired)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something that needs to be addressed in this PR, but: shouldn't this large if/else over an enum be a switch statement?

/// The extractor was stopped with a clean shutdown.
/// But we need to restart it (possibly due to a revision change).
/// </summary>
RestartRequired
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick that you don't have to address, but: adding a comma at the end will prevent an unnecessary modification of this line the next time an enum member is added.

{
using var internalTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_source.Token);
TExtractor extractor;
var shouldRestart = false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't used in the first try, so I think it should be declared above the second one, so that its limited scope is more clear.

return ExtractorRunResult.Error;
}

if (shouldRestart)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line above to visually differentiate this from the try/catch.

On a related note: this is a 100-line function that has got three quite distinct parts: the creation of the extractor, the waiting for the extractor or the "revision" change event, and the final restart check. I recommend splitting out the first two into separate functions - but that doesn't need to be done in this PR.

@aasmundeldhuset aasmundeldhuset added waiting-for-team Waiting for the submitter or reviewer of the PR to take an action and removed waiting-for-risk-review Waiting for a member of the risk review team to take an action labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk-review-ongoing Risk review is in progress waiting-for-team Waiting for the submitter or reviewer of the PR to take an action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants